﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ProjectFinal {
	public partial class frmPatron : Form {
		public frmPatron() {
			InitializeComponent();
		}

		private void btn_cancel_Click(object sender, EventArgs e) {
			this.Close();
		}

		private void btn_addPatron_Click(object sender, EventArgs e) {
			bool ok = true;	//assume all is well

			if(tb_name.Text.Trim().Equals("")) {  //Must have a name
				MessageBox.Show("Please enter a name.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
				ok = false;
			}
			if(!rb_adult.Checked && !rb_child.Checked) {  //Must be either Adult or Child
				MessageBox.Show("Please select Adult or Child.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
				ok = false;
			}
			if(!ok) return;

			//If everything is valid, make a new Patron
			BusinessRules.newPatron(tb_name.Text, rb_adult.Checked);
			BusinessRules.sortPatrons();
			this.Close();
		}
	}
}
